<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>外卖管理系统</title>
<link rel="stylesheet" href="/css/admin.css" type="text/css"/>
<script type="text/javascript" src="/js/jquery-1.6.1.min.js"></script>
</head>
<body leftmargin="2" topmargin="2">
<s:form id="create" action="admin_scriptorium" onsubmit="VF_scriptoriumflag();return false;">
<s:hidden name="action" />
<s:hidden name="id" />
 <fieldset><legend>
 <s:if test="%{action=='doadd'}">添加写字楼方式</s:if>
 <s:if test="%{action=='doupdate'}">修改写字楼方式</s:if>
 </legend>
 <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <COLGROUP>
  <COL width="100" />
  <COL width="*" />
    <tr class="tdbg2"> 
      <td align="right" >名称：</td>
      <td><s:textfield id="scrName" name="scrName" size="20"/></td>
    </tr>
    <tr class="tdbg3"> 
      <td align="right">首 字 母：</td>
      <td><s:textfield id="scrInitials" name="scrInitials" size="20"/></td>
    </tr>
    <!-- 
    <tr class="tdbg2"> 
      <td align="right">简  拼：</td>
      <td><s:textfield id="scrAnglic" name="scrAnglic" size="20"/></td>
    </tr>
    <tr class="tdbg3"> 
      <td align="right">全  拼：</td>
      <td><s:textfield id="scrPhonetic" name="scrPhonetic" size="20"/></td>
    </tr>
     -->
    <tr class="tdbg3"> 
      <td align="right">类  型：</td>
      <td><s:select list="scriptoriumTypeList" name="scrType" id="scrType" listKey="key" listValue="value"></s:select></td>
    </tr>
    <tr class="tdbg3"> 
      <td align="right">城   市：</td>
      <td><s:select list="cityList" name="cityId" id="cityId" listKey="key" listValue="value" onchange="onarea(this.value)"></s:select></td>
    </tr>
    <tr class="tdbg3"> 
      <td align="right">地   区：</td>
      <td><s:select list="areaList" name="areaId" id="areaId" listKey="key" listValue="value"></s:select></td>
    </tr>
    <tr class="tdbg3"> 
      <td align="right">是否显示：</td>
      <td><s:select list="isShowList" name="isShow" id="isShow" listKey="key" listValue="value"></s:select></td>
    </tr>
	<tr class="tdbg3"> 
      <td align="right">排  序：</td>
      <td><s:textfield id="orderNum" name="orderNum" size="20"/></td>
    </tr>
     <tr class="tdbg3">
      <td colspan="2" align="center"><s:submit value="提交"/></td>
    </tr>
</table></fieldset>
</s:form>
<script type="text/javascript">
function VF_scriptoriumflag(){ 
    var errMsg = "";
    if(isNaN($('#orderNum').val())){
		errMsg = "排序请添写数字！";
	}
	if ($('#isShow').val() == -1){
        errMsg = "请选择显示信息！";
    }
    if ($('#areaId').val() == -1){
        errMsg = "请选择地区！";
    }
    if ($('#cityId').val() == -1){
        errMsg = "请选择城市！";
    }
    if ($('#scrType').val() == -1){
        errMsg = "请选择类型！";
    }
    if ($('#scrPhonetic').val() == ""){
        errMsg = "请填写全拼！";
    }
    if ($('#scrAnglic').val() == ""){
        errMsg = "请填写简拼！";
    }
	if ($('#scrInitials').val() == ""){
        errMsg = "请填写首字母！";
    }
    if ($('#scrName').val() == ""){
        errMsg = "请填写名称！";
    }
    if (errMsg != ""){
        alert(errMsg);
    }else{
		document.getElementById('create').submit();
	}
}
var areas=new Array();
<s:iterator id="a" value="%{areas}" status="st" >
areas[areas.length]=new Array(<s:property value="#a.id"/>,<s:property value="#a.cityId"/>,'<s:property value="#a.areaName"/>');
</s:iterator>
function onarea(cityId){
	$('#areaId').empty();
	$('#areaId').append("<option value='-1'>请选择</option>");   
   for(i=0;i<areas.length;i++){
   	if(cityId == areas[i][1]){
		$('#areaId').append("<option value='"+areas[i][0]+"'>"+areas[i][2]+"</option>");
   	}
   }
}
</script>
</body>
</html>
